
var $window = $(window), gardenCtx, gardenCanvas, $garden, garden;
var clientWidth = $(window).width();
var clientHeight = $(window).height();

var R=10；

$(function () {
    // setup garden
	$loveHeart = $("#loveHeart");
	var offsetX = $loveHeart.width();// / 2;
	var offsetY = $loveHeart.height() -55;/// 2 - 55;
    $garden = $("#garden");
    gardenCanvas = $garden[0];
	gardenCanvas.width = $("#loveHeart").width();
    gardenCanvas.height = $("#loveHeart").height()
    gardenCtx = gardenCanvas.getContext("2d");
    gardenCtx.globalCompositeOperation = "lighter";
    garden = new Garden(gardenCtx, gardenCanvas);
    // renderLoop
    setInterval(function () {
        garden.render();
    }, 50);
});


function startHeartAnimation() {
	setInterval(function () {
    for (var i = 0; i < digit[num].length; i++)
        for (var j = 0; j < digit[num][i].length; j++)
            if (digit[num][i][j] == 1) {
                garden.createRandomBloom(x + j * 2 * (R + 1) + (R + 1), y + i * 2 * (R + 1) + (R + 1));
            }
	}, 50);
}
